package com.base.service;

import java.math.BigDecimal;
import java.util.Date;
import java.util.List;
import java.util.Map;

import com.base.po.requestParam.SubscribersParam;
import com.base.po.voip.*;
import com.base.po.voip_sdk.SubscribersResponse;
import org.apache.ibatis.annotations.Param;

import com.base.po.sqlparam.SubscribersExamplePage;
import com.base.utils.Page;

/**
 *
 */
public interface SubscribersService {
	int countByExample(SubscribersExample example);

	int deleteByExample(SubscribersExample example);

	int deleteByPrimaryKey(String id);

	int insert(String password, Date logintime, String loginip, Integer role, Boolean datastatus, String mobile,
               String parentid, Date endtime, String pic, Integer type, String shopid, String appstore, Float integral,
               String aliaccount, Boolean alipay, Integer shopBalance, String shopEnddate, String birthday, String gender,
               String email, String address, String username, Boolean isyear, Boolean ismonth, Boolean isquarter);

	int insertSelective(Subscribers record);

	List<Subscribers> selectByExample(SubscribersExample example);

	List<Subscribers> selectByExamplePage(SubscribersExamplePage example);

	List<Subscribers> selectByParentId(String parentid);

	List<Subscribers> selectBySharePer(String shareper);

	List<Subscribers> selectBySharePerJSJ(String shareper);

	List<String> selectByMobile(@Param("mobile") String mobile);

	List<String> selectByMobileAndParentId(@Param("mobile") String mobile, @Param("parentid") String parentid);

	Subscribers selectBySubscribers(@Param("mobile") String mobile, @Param("parentid") String parentid);
	
	List<Subscribers> selectBySub(@Param("mobile") String mobile, @Param("parentid") String parentid);

	List<SubscribersResponse> selectBySubForSbd(@Param("mobile") String mobile, @Param("parentid") String parentid);

	List<Subscribers> selectAllSub(@Param("parentid") String parentid, @Param("isnull") Integer isnull);

	List<String> selectByMobileAndShopId(@Param("mobile") String mobile, @Param("shopid") String shopid);

	List<Subscribers> selectByAllForExport(@Param("username") String username, @Param("parentid") String parentid,
										   @Param("shopid") String shopid, @Param("startTimeFrom") String startTimeFrom,
										   @Param("startTimeTo") String startTimeTo, @Param("start") Integer start, @Param("size") Integer size);

	List<Subscribers> selectByAll(@Param("page") Page page, @Param("shareper") String shareper,
								  @Param("mobile") String mobile, @Param("username") String username,
								  @Param("parentid") String parentid, @Param("shopid") String shopid, @Param("datastatus") Boolean datastatus,
								  @Param("startTimeFrom") String startTimeFrom, @Param("startTimeTo") String startTimeTo,
								  @Param("endTimeFrom") String endTimeFrom, @Param("endTimeTo") String endTimeTo);

	List<Subscribers> selectByParentid(@Param("page") Page page, @Param("parentid") String parentid, @Param("shareper") String shareper,
									   @Param("mobile") String mobile, @Param("username") String username, @Param("id") String id, @Param("shopid") String shopid,
									   @Param("datastatus") Boolean datastatus, @Param("startTimeFrom") String startTimeFrom,
									   @Param("startTimeTo") String startTimeTo, @Param("endTimeFrom") String endTimeFrom,
									   @Param("endTimeTo") String endTimeTo);

	List<Subscribers> selectByShopid(@Param("page") Page page, @Param("shopid") String shopid,
									 @Param("mobile") String mobile, @Param("id") String id, @Param("datastatus") Boolean datastatus,
									 @Param("startTimeFrom") String startTimeFrom, @Param("startTimeTo") String startTimeTo,
									 @Param("endTimeFrom") String endTimeFrom, @Param("endTimeTo") String endTimeTo);

	List<Subscribers> selectByShopidNotAll(@Param("page") Page page, @Param("shopid") String shopid, @Param("shareper") String shareper,
										   @Param("mobile") String mobile, @Param("username") String username, @Param("id") String id, @Param("datastatus") Boolean datastatus,
										   @Param("startTimeFrom") String startTimeFrom, @Param("startTimeTo") String startTimeTo,
										   @Param("endTimeFrom") String endTimeFrom, @Param("endTimeTo") String endTimeTo);

	Subscribers selectByPrimaryKey(String id);

	Subscribers selectByIsOpen(String isopenmember);

	Subscribers selectByPid(String parentid, String pid);

	Subscribers selectByRebatePid(@Param("parentid") String parentid, @Param("rebatepid") String rebatepid);

	Subscribers selectBySpecialId(@Param("parentid") String parentid, @Param("specialId") String specialId);

	Subscribers selectByPddPid(@Param("parentid") String parentid, @Param("pddPid") String pddPid);

	Subscribers selectByJdPid(@Param("parentid") String parentid, @Param("jdPid") String jdPid);

	List<Subscribers> selectByWxOpenId(@Param("wxOpenId") String wxOpenId,@Param("ParentId")String ParentId);

	List<Subscribers> selectByAppleUserId(@Param("appleUserId") String appleUserId, @Param("ParentId") String ParentId);

	int updateByExampleSelective(@Param("record") Subscribers record, @Param("example") SubscribersExample example);

	int updateByExample(@Param("record") Subscribers record, @Param("example") SubscribersExample example);

	int updateByPrimaryKeySelective(Subscribers record);

	int updateByPrimaryKey(Subscribers record);

	int countByAll(@Param("shareper") String shareper, @Param("mobile") String mobile, @Param("username") String username,
				   @Param("parentid") String parentid, @Param("shopid") String shopid,
				   @Param("datastatus") Boolean datastatus, @Param("startTimeFrom") String startTimeFrom,
				   @Param("startTimeTo") String startTimeTo, @Param("endTimeFrom") String endTimeFrom,
				   @Param("endTimeTo") String endTimeTo);

	int countByParentid(@Param("parentid") String parentid, @Param("shareper") String shareper,
						@Param("mobile") String mobile, @Param("username") String username, @Param("id") String id,
						@Param("shopid") String shopid, @Param("datastatus") Boolean datastatus,
						@Param("startTimeFrom") String startTimeFrom, @Param("startTimeTo") String startTimeTo,
						@Param("endTimeFrom") String endTimeFrom, @Param("endTimeTo") String endTimeTo);

	int countByShopid(@Param("shopid") String shopid, @Param("mobile") String mobile, @Param("id") String id,
					  @Param("datastatus") Boolean datastatus, @Param("startTimeFrom") String startTimeFrom,
					  @Param("startTimeTo") String startTimeTo, @Param("endTimeFrom") String endTimeFrom,
					  @Param("endTimeTo") String endTimeTo);

	int countByShopidNotAll(@Param("shopid") String shopid, @Param("shareper") String shareper,
							@Param("mobile") String mobile, @Param("username") String username, @Param("id") String id,
							@Param("datastatus") Boolean datastatus, @Param("startTimeFrom") String startTimeFrom,
							@Param("startTimeTo") String startTimeTo, @Param("endTimeFrom") String endTimeFrom,
							@Param("endTimeTo") String endTimeTo);

	/**
	 * 用户总数
	 * 
	 * @param parentid 商家/代理商ID
	 * @return
	 */
	int selectByCount(String parentid, Date begin, Date end);

	int selectByCountShop(String shopid, Date begin, Date end);

	// 商家的购物消费统计
	Subscribers countByShopSA(String shopid, String mobile, String username, String shopname);

	List<Subscribers> selectByShopSA(Page page, String shopid, String mobile, String username, String shopname);

	// 代理商的购物消费统计
	Subscribers countByShopPA(String parentid, String mobile, String username, String shopname);

	List<Subscribers> selectByShopPA(Page page, String parentid, String mobile, String username, String shopname);

	// 商家的购物消费统计
	Subscribers countByCallSA(String shopid, String mobile, String username, String shopname);

	List<Subscribers> selectByCallSA(Page page, String shopid, String mobile, String username, String shopname);

	// 代理商的购物消费统计
	Subscribers countByCallPA(String parentid, String mobile, String username, String shopname);

	List<Subscribers> selectByCallPA(Page page, String parentid, String mobile, String username, String shopname);

	// 获取当前用户的粉丝信息
	int countByPer(String perid);

	List<Subscribers> selectByPer(Page page, String perid);

	// 获取分红人数
	int selectByBonus(@Param("parentid") String parentid, @Param("shopid") String shopid, @Param("bonus1level") Integer bonus1level,
					  @Param("bonus2level") Integer bonus2level, @Param("bonus3level") Integer bonus3level);

	List<Subscribers> selectBonusByAll(@Param("page") Page page, @Param("bonus1level") Integer bonus1level,
									   @Param("bonus2level") Integer bonus2level, @Param("bonus3level") Integer bonus3level);

	List<Subscribers> selectBonusByParentid(@Param("page") Page page, @Param("parentid") String parentid,
											@Param("bonus1level") Integer bonus1level, @Param("bonus2level") Integer bonus2level,
											@Param("bonus3level") Integer bonus3level);

	List<Subscribers> selectBonusByShopidNotAll(@Param("page") Page page, @Param("shopid") String shopid,
												@Param("bonus1level") Integer bonus1level, @Param("bonus2level") Integer bonus2level,
												@Param("bonus3level") Integer bonus3level);

	int countBonusByAll(@Param("bonus1level") Integer bonus1level, @Param("bonus2level") Integer bonus2level,
						@Param("bonus3level") Integer bonus3level);

	int countBonusByParentid(@Param("parentid") String parentid, @Param("bonus1level") Integer bonus1level,
							 @Param("bonus2level") Integer bonus2level, @Param("bonus3level") Integer bonus3level);

	int countBonusByShopidNotAll(@Param("shopid") String shopid, @Param("bonus1level") Integer bonus1level,
								 @Param("bonus2level") Integer bonus2level, @Param("bonus3level") Integer bonus3level);

	/**
	 * 获取代理商紧急控制信息
	 * @param parentId   代理商ID
 	 * @return
	 */
	List<Agentinfoes> findParentAgentInfo(String parentId);

	/**
	 * 顺通
	 */
	List<Subscribers> selectNextPer1(String userId);

	List<Subscribers> selectNextPer2(String userId);

	List<Subscribers> selectNextPer3(String userId);

	List<Subscribers> selectNextPer4(String userId);

	List<Subscribers> selectNextPer5(String userId);

	Subscribers selectsomeByPrimaryKey(String userid);

	List<Subscribers> selectByShopIdOnly(String shopid);

	int updateWxUntying(String id);

    int hasSub(String mobile, String parentId);

    List<String> selectMobiles(String userid);

	int updateIsUserAuthById(@Param("id") String id);

	List<String> selectForShareId(@Param("shareId") String shareId);

	List<String> selectMemberForShareId(@Param("shareId") String shareId);

	List<String> selectForSharePer(@Param("list") List<String> list);

	List<String> selectForTeamCommission(@Param("shareId") String shareId, @Param("list") List<String> list);

	List<Subscribers> selectForDirect(@Param("shareId") String shareId, @Param("page") Page page);

	int countForDirect(@Param("shareId") String shareId);

	Boolean isUserAuth(@Param("id") String id);

	/**
	 * 查询所有上级
	 */
	List<String> findParList(String userId);
	/**
	 * 查询所有下级
	 */
	List<String> findChildList(String userId);

	/**
	 * 修改用户信息
	 * @param param 用户请求参数
	 * @return int 0失败 1成功
	 */
	int update(SubscribersParam param);

	/**
	 * 获取子级代理
	 * @param userId 用户id
	 */
    List<ChildrenAgent> getChildrenAgent(String userId);
	/**
	 * 获取子级代理人数
	 */
    Integer getChildrenAgentNum(List<ChildrenAgent> list);

	/**
	 * 一级代理人数
	 */
	Integer countByMenber();

	/**
	 * 获取一级代理数据
	 * @param page
	 */
	List<Daili> selectDaili(Page page);

	/**
	 * 团队总业绩
	 */
    BigDecimal getTeamTotalPrice(String userId);

	/**
	 * 团队拼团成功总数
	 */
	Integer getTeamPtSuccessNum(String userId);
}